﻿<UserControl x:Class="SSDM.DocumentingDB.ShowDBSchemaWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:BaseControl="clr-namespace:MPL;assembly=MPL"
    xmlns:WPFToolKits="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit">
    <Grid>
        <DockPanel LastChildFill="True">
            <CheckBox x:Name="chkIsEditable"
                      Checked="chkIsEditable_Checked" Unchecked="chkIsEditable_Unchecked"
                      Content="Is editable" DockPanel.Dock="Bottom" HorizontalAlignment="Right" Margin="0 0 10 0"/>
            <DataGrid MinHeight="50"
                     x:Name="myGrid" IsReadOnly="True"
                     ItemsSource="{Binding}"
                     Margin="10"
                     CanUserResizeColumns="False"
                     AutoGenerateColumns="False"       
                     CanUserAddRows="True"
                     CanUserDeleteRows="True"
                     Background="Transparent"
                     GridLinesVisibility="All"
                     RowHeaderWidth="10"                     
                     SelectionMode="Extended"
                     SelectionUnit="FullRow"
                     HeadersVisibility="All"
                     RowBackground="White" 
                     AlternatingRowBackground="AliceBlue"
                     AlternationCount="2" 
                     ScrollViewer.HorizontalScrollBarVisibility="Visible"
                     >
                <DataGrid.Columns>
                    <DataGridTextColumn Width="80" Header="Table Name">
                        <DataGridTextColumn.Binding>
                            <Binding Path="TableName" Mode="TwoWay" ValidatesOnDataErrors="True" 
                                     ValidatesOnExceptions="True" UpdateSourceTrigger="PropertyChanged">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridTextColumn Width="80" Header="Column Name">
                        <DataGridTextColumn.Binding>
                            <Binding Path="ColumnName" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridTextColumn Width="80" Header="Ordinary Position">
                        <DataGridTextColumn.Binding>
                            <Binding Path="OrdinaryPosition" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridComboBoxColumn IsReadOnly="False" 
                            x:Name="category" 
                            TextBinding="{Binding Path=Category, Mode=TwoWay}"
                            Width="80" Header="Category">
                    </DataGridComboBoxColumn>
                    <DataGridTextColumn Width="50" Header="Type">
                        <DataGridTextColumn.Binding>
                            <Binding Path="DbType" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridTextColumn Width="50" Header="Length">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Length" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridTextColumn Width="60" Header="Format">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Format" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridTemplateColumn Width="100" Header="Revision Date">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <DatePicker Text="{Binding Path=RevisionDate,Mode=TwoWay}" HorizontalAlignment="Center" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Width="80" Header="Revision Note">
                        <DataGridTextColumn.Binding>
                            <Binding Path="RevisionNote" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridTextColumn Width="80" Header="Description">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Description" Mode="TwoWay">
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                    <DataGridCheckBoxColumn Width="80" Header="Is Primary Key">
                        <DataGridCheckBoxColumn.Binding>
                            <Binding Path="IsPrimaryKey" Mode="TwoWay">
                            </Binding>
                        </DataGridCheckBoxColumn.Binding>
                    </DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Width="80" Header="Is Index">
                        <DataGridCheckBoxColumn.Binding>
                            <Binding Path="IsIndex" Mode="TwoWay">
                            </Binding>
                        </DataGridCheckBoxColumn.Binding>
                    </DataGridCheckBoxColumn>
                </DataGrid.Columns>
            </DataGrid>
        </DockPanel>
        
    </Grid>
</UserControl>
